/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32l4xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#define UART_BUF_NUB   150
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define EN_1V8_Pin GPIO_PIN_1
#define EN_1V8_GPIO_Port GPIOA
#define A121_SPI_SS_Pin GPIO_PIN_6
#define A121_SPI_SS_GPIO_Port GPIOC
#define A121_INT_Pin GPIO_PIN_12
#define A121_INT_GPIO_Port GPIOB
#define A121_EN_Pin GPIO_PIN_7
#define A121_EN_GPIO_Port GPIOC
//#define OUT1_Pin GPIO_PIN_0
//#define OUT1_GPIO_Port GPIOB
//#define OUT2_Pin GPIO_PIN_1
//#define OUT2_GPIO_Port GPIOB
//#define RE485_Pin GPIO_PIN_2
//#define RE485_GPIO_Port GPIOB
#define LED2_Pin GPIO_PIN_4
#define LED2_GPIO_Port GPIOC
#define LED1_Pin GPIO_PIN_7
#define LED1_GPIO_Port GPIOA

/* USER CODE BEGIN Private defines */
#define A121_SPI_HANDLE     hspi2

#define POWER_ON   HAL_GPIO_WritePin(EN_1V8_GPIO_Port, EN_1V8_Pin, GPIO_PIN_SET);
#define POWER_OFF  HAL_GPIO_WritePin(EN_1V8_GPIO_Port, EN_1V8_Pin, GPIO_PIN_RESET);

#define OUT1_ON   HAL_GPIO_WritePin(OUT1_GPIO_Port, OUT1_Pin, GPIO_PIN_SET);
#define OUT1_OFF  HAL_GPIO_WritePin(OUT1_GPIO_Port, OUT1_Pin, GPIO_PIN_RESET);


#define OUT2_ON   HAL_GPIO_WritePin(OUT2_GPIO_Port, OUT2_Pin, GPIO_PIN_SET);
#define OUT2_OFF  HAL_GPIO_WritePin(OUT2_GPIO_Port, OUT2_Pin, GPIO_PIN_RESET);


#define A121_SPI_SS_ON   HAL_GPIO_WritePin(A121_SPI_SS_GPIO_Port, A121_SPI_SS_Pin, GPIO_PIN_SET);
#define A121_SPI_SS_OFF  HAL_GPIO_WritePin(A121_SPI_SS_GPIO_Port, A121_SPI_SS_Pin, GPIO_PIN_RESET);

#define A121_EN_ON   HAL_GPIO_WritePin(A121_EN_GPIO_Port, A121_EN_Pin, GPIO_PIN_SET);
#define A121_EN_OFF  HAL_GPIO_WritePin(A121_EN_GPIO_Port, A121_EN_Pin, GPIO_PIN_RESET);


#define LED1_ON   HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET);
#define LED1_tog  HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
#define LED1_OFF  HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET);

#define LED2_ON   HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET);
#define LED2_OFF  HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET);
#define LED2_tog  HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);

#define READ_A121_INT  HAL_GPIO_ReadPin(A121_INT_GPIO_Port, A121_INT_Pin)

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
